﻿using EONFULLSIN2.Common;
using EONFULLSIN2.Models.Entity.User;
using EONFULLSIN2.Services.DB;
using FreeSql;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EONFULLSIN2.Core.Helpers
{
    /// <summary>
    /// 数据库辅助类
    /// </summary>
    public class DBHelper
    {
        /// <summary>
        /// 创建数据
        /// </summary>
        public static void CraeteData()
        {
            User user = new User()
            {
                Account = "SuperAdmin",
                PassWord = "root123456",
                Name = "SuperAdmin",
                IsAdmin = true,
                Rank = Models.Enum.eRoleTypeEnum.Admin,
                CreatedTime = DateTime.Now,
                Status = true,
                Soft = 1
            };
            var dbContext = PrismIocInfo.GetInstanceByIoc<IDbOperate<IFreeSqlMainContext>>();
            var res = dbContext.GetModel<User>(p => p.Account == user.Account);
            if (res == null)
            {
                var rlt = dbContext.AddModel(user);
            }
        }


    }
}
